package com.fjwt.gz.service.impl;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import com.fjwt.gz.components.mq.websocket.server.MinProgramWsChannelServer;
import com.fjwt.gz.core.constants.Constants;
import com.fjwt.gz.core.exception.BizException;
import com.fjwt.gz.core.utils.SpringBeansUtil;
import com.fjwt.gz.db.bo.ActivityAwardAndSettingBo;
import com.fjwt.gz.db.dto.FansActivityDTO;
import com.fjwt.gz.db.dto.FansAuthDTO;
import com.fjwt.gz.db.dto.FansAwardDTO;
import com.fjwt.gz.db.entity.*;
import com.fjwt.gz.db.vo.*;
import com.fjwt.gz.service.activity.BaseActivityService;
import com.fjwt.gz.service.mapper.FansAwardMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * <p>
 * 会员奖品表 服务实现类
 * </p>
 *
 * @author shiyonghao
 * @since 2025-04-09
 */
@Slf4j
@Service
public class FansAwardService extends ServiceImpl<FansAwardMapper, FansAwardEntity> {

    @Autowired
    private AgentEmployeeService agentEmployeeService;
    @Autowired
    private FansAwardMapper fansAwardMapper;
    @Autowired
    private AgentInfoService agentInfoService;
    @Autowired
    private SendAwardService sendAwardService;
    @Autowired
    private ActivityAwardService activityAwardService;
    @Autowired
    private FansAgentService fansAgentService;
    @Autowired
    private AwardAgentService awardAgentService;
    @Autowired
    private AwardSettingService awardSettingService;
    @Autowired
    private AwardGoodsService awardGoodsService;
    @Autowired
    private OnlyOneAwardService onlyOneAwardService;
    @Autowired
    private MinProgramWsChannelServer wsChannelServer;


    /**
     * 查询5分钟内是否兑换过卡券
     *
     * @return
     */
    public Integer selectRecord(String date, Long fansId, String scoreExchangeId, Integer infoType) {
        log.info("查询记录，date:{},fansId:{},scoreExchangeId:{},infoType:{}", date, fansId, scoreExchangeId, infoType);
        List<FansAwardDTO> fansAwardDTOS = baseMapper.selectRecord(date, fansId, scoreExchangeId, infoType);
        if (fansAwardDTOS != null && !fansAwardDTOS.isEmpty()) {
            return 1;
        }
        return 0;
    }

    public IPage<FansCouponsVo> selectListBycouponState(IPage<?> page, Long fansId, Long couponState, Long awardType, Long virtualType, Long virtualState, String appId) {
        if (awardType == 0) {
            IPage<FansCouponsVo> fansCouponsVoIPage1 = baseMapper.selectListBycouponState(page, fansId, couponState, awardType, appId);
            return fansCouponsVoIPage1;
        } else if (awardType == 1) {
            IPage<FansCouponsVo> fansCouponsVoIPage2 = baseMapper.selectListByGoodsState(page, fansId, couponState, awardType, appId);
            return fansCouponsVoIPage2;
        } else if (awardType == 2) {
            if (virtualType == 0) {
                IPage<FansCouponsVo> fansCouponsVoIPage3 = baseMapper.selectListByCDKState(page, fansId, couponState, awardType, virtualType, appId);
                return fansCouponsVoIPage3;
            } else if (virtualType == 1) {
                IPage<FansCouponsVo> fansCouponsVoIPage3 = baseMapper.selectListByvirtualState(page, fansId, couponState, awardType, virtualType, virtualState, appId);
                return fansCouponsVoIPage3;
            }
        }
        return null;
    }

    /**
     * 获取发放卡券列表
     *
     * @param iPage
     * @param activityId
     * @return
     */
    public IPage<AwardCouponVO> sendCouponList(IPage iPage, Long activityId, String phone, String nickName, String realName, String createdAt, Long fansId, String agentNo, String appId) {
        if (ObjectUtils.isEmpty(fansId)) {
            throw new BizException("参数异常");
        }
        // 查询客户经理所绑定机构
        FansAgentEntity fansAgentEntity = fansAgentService.getOne(FansAgentEntity.gw().eq(FansAgentEntity::getFansId, fansId).eq(FansAgentEntity::getAppId, appId).eq(FansAgentEntity::getIsDeleted, 0));
        if (ObjectUtils.isEmpty(fansAgentEntity) || ObjectUtils.isEmpty(fansAgentEntity.getAgentEmployeeId())) {
            throw new BizException("未查询到所绑定机构");
        }
        AgentEmployeeEntity agentEmployee = agentEmployeeService.getOne(AgentEmployeeEntity.gw().eq(AgentEmployeeEntity::getAgentEmployeeId, fansAgentEntity.getAgentEmployeeId()));
        if (ObjectUtils.isEmpty(agentEmployee) || ObjectUtils.isEmpty(agentEmployee.getAgentNo())) {
            throw new BizException("未查询到所绑定机构");
        }
        AgentInfoEntity agentInfo = agentInfoService.getById(agentEmployee.getAgentNo());
        if (ObjectUtils.isEmpty(agentInfo)) {
            throw new BizException("机构状态异常");
        }
        return fansAwardMapper.sendCouponList(iPage, activityId, phone, nickName, realName, createdAt, agentInfo.getAgentNo(), agentInfo.getLevel());
    }

    /**
     * 卡券领用详情
     *
     * @param fansAwardId
     * @return
     */
    public AwardCouponVO fansCouponDetail(Long fansAwardId, String locationAgentNo) {
        return fansAwardMapper.fansCouponDetail(fansAwardId, locationAgentNo);
    }

    /**
     * 查询用户活动卡券奖品列表
     *
     * @param fansActivityDTO
     * @return
     */
    public List<FansCouponsVo> findFansActivateCoupons(FansActivityDTO fansActivityDTO) {
        return baseMapper.selectFansActivateCoupons(fansActivityDTO);
    }

    /**
     * 查询活动已激活/已使用卡券用户列表
     *
     * @param fansActivityDTO
     * @return
     */
    public List<FansAwardDTO> findActivityUnusedCoupon(FansActivityDTO fansActivityDTO) {
        return baseMapper.selectActivityUnusedCoupon(fansActivityDTO);
    }

    /**
     * 过期ACTE028其他待激活卡券
     *
     * @param fansAwardEntity
     * @param extraJson
     */
    public void disableACTE028Award(FansAwardEntity fansAwardEntity, JSONObject extraJson) {
        // 过期该活动其他待激活卡券
        LambdaUpdateWrapper<FansAwardEntity> gw = new LambdaUpdateWrapper<>();
        gw.eq(FansAwardEntity::getFansId, fansAwardEntity.getFansId())
                .eq(FansAwardEntity::getState, Constants.FANS_AWARD_STATE.ACTIVATE)
                .like(FansAwardEntity::getExtraJson, extraJson.getInteger("activityId"))
                .like(FansAwardEntity::getExtraJson, extraJson.getString("templateNo"))
                .ne(ObjectUtils.isNotEmpty(fansAwardEntity.getRemark()), FansAwardEntity::getRemark, fansAwardEntity.getRemark())
                .set(FansAwardEntity::getState, Constants.FANS_AWARD_STATE.DISABLED);
        boolean update = SqlHelper.retBool(baseMapper.update(gw));
        if (update) {
            log.info("该用户fansId：{}该活动同类型待激活的商户资产提升奖品已全部失效", fansAwardEntity.getFansId());
        }
    }

    /**
     * Abc查询用户某个活动卡券领取情况
     **/
    public List<FansAwardEntity> getFansAwardsByCondition(FansAwardDTO fansAwardDTO) {
        return baseMapper.getFansAwardsByCondition(fansAwardDTO);
    }

    /**
     * ACTE008卡券导出EXCEL
     *
     * @param awardId
     * @return
     */
    public List<ExportAwardVO> exportACTE008CouponAward(List<Long> awardIds) {
        return baseMapper.exportACTE008CouponAward(awardIds);
    }

    /**
     * ACTE008实物信息
     *
     * @param awardId
     * @return
     */
    public List<ExportAwardVO> exportACTE008GoodsAward(List<Long> awardIds) {
        return baseMapper.exportACTE008GoodsAward(awardIds);
    }

    /**
     * 获取卡券激活提示语
     *
     * @param fansAwardDTO
     */
    public String getActivateAlertMsg(FansAwardDTO fansAwardDTO) {
        if (ObjectUtils.isEmpty(fansAwardDTO.getAwardId()) || ObjectUtils.isEmpty(fansAwardDTO.getFansId()) || ObjectUtils.isEmpty(fansAwardDTO.getAppId())) {
            throw new BizException("网络故障，请稍后重试！");
        }
        // 查询卡券配置活动信息及app信息
        ActivityAwardAndSettingBo activityAwardAndSettingBo = activityAwardService.getActivityAndApp(fansAwardDTO.getAwardId(), Constants.AWARD.COUPON);
        if (ObjectUtils.isEmpty(activityAwardAndSettingBo)) {
            throw new BizException("该奖品未配置活动");
        }
        // 校验同主体发券是否参数完整
        fansAwardDTO.setAppId(fansAwardDTO.getAppId());
        sendAwardService.checkActivitySubject(fansAwardDTO.getFansId(), activityAwardAndSettingBo);

        return activityAwardAndSettingBo.getActivateExplain();
    }

    /**
     * 卡券激活
     *
     * @param fansAwardDTO
     */
    @Transactional
    public void activeCoupon(FansAwardDTO fansAwardDTO) {
        if (ObjectUtils.isEmpty(fansAwardDTO.getFansAwardId()) || ObjectUtils.isEmpty(fansAwardDTO.getFansId())) {
            throw new BizException("网络故障，请稍后重试！");
        }
        FansAwardEntity fansAwardEntity = baseMapper.selectById(fansAwardDTO.getFansAwardId());
        log.info("用户获奖记录信息：{}", JSON.toJSONString(fansAwardEntity));
        if (Objects.isNull(fansAwardEntity)) {
            throw new BizException("未找到该奖品信息！");
        } else {
            if (Constants.FANS_AWARD_STATE.ACTIVATE != fansAwardEntity.getState()) {
                throw new BizException("请核实卡券状态！");
            }
            ActivityAwardAndSettingBo activityAwardAndSettingBo = activityAwardService.getActivityAndApp(fansAwardEntity.getAwardId(), fansAwardEntity.getAwardType());
            log.info("卡券信息：{}", JSON.toJSONString(activityAwardAndSettingBo));
            // 查询客户经理所绑定机构
            AgentEmployeeVO fansAgentEmployee = fansAgentService.getFansAgent(fansAwardDTO.getFansId(), fansAwardDTO.getAppId());
            if (ObjectUtils.isEmpty(fansAgentEmployee.getAgentNo())) {
                throw new BizException("未查询到所绑定机构");
            }

            if (1 == activityAwardAndSettingBo.getIsAllocation()) {
                // 查询卡券所配置的机构
                LambdaQueryWrapper<AwardAgentEntity> awardAgentGw = AwardAgentEntity.gw().eq(AwardAgentEntity::getAwardId, fansAwardEntity.getAwardId())
                        .eq(AwardAgentEntity::getAwardType, fansAwardEntity.getAwardType()).eq(AwardAgentEntity::getAgentNo, fansAgentEmployee.getAgentNo());
                AwardAgentEntity agentEntity = awardAgentService.getOne(awardAgentGw);
                if (Objects.isNull(agentEntity)) {
                    throw new BizException("请到活动机构进行卡券激活！");
                }
            }

            // 激活奖品
            sendAwardService.activateAward(fansAwardEntity, activityAwardAndSettingBo, fansAgentEmployee, fansAgentEmployee.getAgentNo(), fansAwardDTO.getReceiptContent());
//            if (ObjectUtils.isNotEmpty(fansAwardId)) {
//                wsChannelServer.convertAndSend(String.valueOf(fansAwardEntity.getFansId()), fansAwardEntity.getAppId(), "奖品激活", "激活成功！");
//            }else {
//                wsChannelServer.convertAndSend(String.valueOf(fansAwardEntity.getFansId()), fansAwardEntity.getAppId(), "奖品激活", "激活失败！");
//            }
            //成功后查询是否需要回调处理接
            if ("ACTE017".equals(fansAwardDTO.getActivityTemplateNo())) {
                BaseActivityService activityService = SpringBeansUtil.getBean(fansAwardDTO.getActivityTemplateNo() + "Service", BaseActivityService.class);
                activityService.fansActiveCoupon(fansAwardEntity);
            }
        }
    }

    /**
     * 用户实物奖品核销
     *
     * @param fansAwardDTO
     * @return
     */
    @Transactional
    public Integer destroyAward(FansAwardDTO fansAwardDTO) {
        if (Objects.isNull(fansAwardDTO.getFansAwardId())) {
            throw new BizException("网络故障，请稍后重试！");
        }
        if (ObjectUtils.isEmpty(fansAwardDTO.getFansId())) {
            throw new BizException("参数异常");
        }
        FansAwardEntity fansAwardEntity = baseMapper.selectById(fansAwardDTO.getFansAwardId());
        if (Objects.isNull(fansAwardEntity)) {
            throw new BizException("该奖励不存在，请核实！");
        }
        Integer state = fansAwardEntity.getState();
        if (Constants.FANS_AWARD_STATE.ACTIVATE != state || fansAwardEntity.getOverTime().before(new Date())) {
            throw new BizException("该奖励已使用或已过期，请核实！");
        }
        LambdaQueryWrapper<AwardSettingEntity> gw =
                AwardSettingEntity.gw()
                        .eq(AwardSettingEntity::getAwardId, fansAwardEntity.getAwardId())
                        .eq(AwardSettingEntity::getAwardType, fansAwardEntity.getAwardType());
        AwardSettingEntity awardSettingEntity = awardSettingService.getOne(gw);
        ActivityAwardAndSettingBo activityAwardAndSettingBo = new ActivityAwardAndSettingBo();
        BeanUtils.copyProperties(awardSettingEntity, activityAwardAndSettingBo);
        // 查询客户经理所绑定机构
        AgentEmployeeVO fansAgentEmployee = fansAgentService.getFansAgent(fansAwardDTO.getFansId(), fansAwardDTO.getAppId());
        if (ObjectUtils.isEmpty(fansAgentEmployee.getAgentNo())) {
            throw new BizException("未查询到所绑定机构");
        }
        if (ObjectUtils.isEmpty(fansAgentEmployee) || ObjectUtils.isEmpty(fansAgentEmployee.getAgentNo())) {
            throw new BizException("未查询到所绑定机构");
        }
        if (1 == activityAwardAndSettingBo.getIsAllocation()) {
            // 查询卡券所配置的机构
            LambdaQueryWrapper<AwardAgentEntity> awardAgentGw =
                    AwardAgentEntity.gw()
                            .eq(AwardAgentEntity::getAwardId, fansAwardEntity.getAwardId())
                            .eq(AwardAgentEntity::getAwardType, fansAwardEntity.getAwardType())
                            .eq(AwardAgentEntity::getAgentNo, fansAgentEmployee.getAgentNo());
            AwardAgentEntity agentEntity = awardAgentService.getOne(awardAgentGw);
            if (Objects.isNull(agentEntity)) {
                throw new BizException("请到活动机构进行卡券激活！");
            }
        }
        sendAwardService.activateAward(fansAwardEntity, activityAwardAndSettingBo, fansAgentEmployee, fansAgentEmployee.getAgentNo(), fansAwardDTO.getReceiptContent());
//        if (ObjectUtils.isNotEmpty(fansAwardId)) {
//            wsChannelServer.convertAndSend(String.valueOf(fansAwardEntity.getFansId()), fansAwardEntity.getAppId(), "奖品核销", "核销成功！");
//        }else {
//            wsChannelServer.convertAndSend(String.valueOf(fansAwardEntity.getFansId()), fansAwardEntity.getAppId(), "奖品核销", "核销失败！");
//        }

        AwardGoodsEntity awardGoodsEntity = awardGoodsService.getById(fansAwardEntity.getAwardId());
        return awardGoodsEntity.getGoodsNum() - awardGoodsEntity.getGoodsGet();
    }

    /**
     * 卡券奖品信息
     * 目前用户 ACTE017,ACTE018,ACTE019
     *
     * @param awardIds
     * @param agentNo
     * @return
     */
    public List<ExportAwardVO> exportCouponAward(List<Long> awardIds, String agentNo) {
        return baseMapper.exportCouponAward(awardIds, agentNo);
    }

    /**
     * 实物奖品信息
     *
     * @param awardIds
     * @return
     */
    public List<ExportAwardVO> exportGoodsAward(List<Long> awardIds) {
        return baseMapper.exportGoodsAward(awardIds);
    }

    /**
     * ACTE004扫码领券导出EXCEL
     *
     * @param awardIds 奖品ids
     * @return
     */
    public List<ExportAwardVO> exportACTE004CouponAward(List<Long> awardIds, String agentNo) {
        return baseMapper.exportACTE004CouponAward(awardIds, agentNo);
    }

    /**
     * 获取发起转介的用户奖品信息
     *
     * @param page
     * @param offsetDate
     * @return
     */
    public IPage<FansAwardVO> findB1ActivateAward(Page page, Date offsetDate, Integer awardType, String templateNo) {
        return baseMapper.findB1ActivateAward(page, offsetDate, awardType, templateNo);
    }

    /**
     * 通过 remark = 'B1' and `state` = 3 用户Id create desc 查询最近的数据
     *
     * @param fansId
     * @return
     */
    public FansAwardVO selectB1CouponAward(Long fansId) {
        return baseMapper.selectB1CouponAward(fansId);
    }

    /**
     * 通过 remark = 'B1' and `state` = 3 用户Id 用户奖品ID 查询数据
     *
     * @param fansId
     * @param fansAwardId
     * @return
     */
    public List<FansAwardEntity> selectB1CouponAwards(Long fansId, Long fansAwardId) {
        return baseMapper.selectB1CouponAwards(fansId, fansAwardId);
    }

    /**
     * 是否参与过实名认证类活动
     *
     * @param fansId
     */
    public boolean isJoinRealNameAuth(Long fansId, String agentNo) {
        LambdaQueryWrapper<OnlyOneAwardEntity> gw = OnlyOneAwardEntity.gw()
                .eq(OnlyOneAwardEntity::getFansId, fansId)
                .eq(OnlyOneAwardEntity::getTag, Constants.FANS_AWARD_TAG.REAL_NAME_AUTH)
                .eq(OnlyOneAwardEntity::getAgentNo, agentNo)
                .eq(OnlyOneAwardEntity::getState, Constants.ONLY_ONE_AWARD_STATE.VALID);
        List<OnlyOneAwardEntity> list = onlyOneAwardService.list(gw);
        if (list != null && !list.isEmpty()) {
            log.info("该用户fansId：{} 已在该机构：{} 参加过同类型(待激活的、待使用的、已使用的)的实名认证活动，次数为：{}", fansId, agentNo, list.size());
            return true;
        } else {
            return false;
        }
    }

    /**
     * 活动奖品列表
     *
     * @param fansId
     * @param awardId
     * @param awardType
     * @param remark
     * @return
     */
    public List<FansAwardEntity> selectListFansAward(Long fansId, Long awardId, Integer awardType, String remark, String flag) {
        return baseMapper.selectListFansAward(fansId, awardId, awardType, remark, flag);
    }

    public String getCdk(Long fansAwardId, Long fansId) {
        LambdaQueryWrapper<FansAwardEntity> gw = FansAwardEntity.gw();
        gw.eq(FansAwardEntity::getFansAwardId, fansAwardId);
        gw.eq(FansAwardEntity::getFansId, fansId);
        FansAwardEntity fansAwardEntity = baseMapper.selectOne(gw);
        if (ObjectUtils.isEmpty(fansAwardEntity) || ObjectUtils.isEmpty(fansAwardEntity.getExtraJson())) {
            throw new BizException("奖品异常，请重试");
        }
        JSONObject extraJson = JSONObject.parseObject(fansAwardEntity.getExtraJson());
        return extraJson.getString("cdk");
    }

    /**
     * 查询用户是否已经被邀请
     *
     * @param fansId
     * @return
     */
    public List<FansAwardEntity> fansActiveCouponBefore(Long fansId) {
        return fansAwardMapper.fansActiveCouponBefore(fansId);
    }

    /**
     * 扫码派券导出EXCEL
     *
     * @param awardIds
     * @return
     */
    public List<ExportAwardVO> exportACTE006CouponAward(List<Long> awardIds) {
        return fansAwardMapper.exportACTE006CouponAward(awardIds);
    }

    /**
     * 013活动导出报表EXCEL
     *
     * @param awardId 奖品id
     * @param agentNo 机构编号
     * @return 奖品列表
     */
    public List<ExportAwardVO> exportAct013CouponAward(List<Long> awardId, String agentNo) {
        return fansAwardMapper.exportAct013CouponAward(awardId, agentNo);
    }

    /**
     * 015 016活动导出报表EXCEL
     *
     * @param awardId 奖品id
     * @param agentNo 机构编号
     * @return 奖品列表
     */
    public List<ExportAwardVO> exportWxDiscountsCouponAward(List<Long> awardId, String agentNo) {
        return fansAwardMapper.exportWxDiscountsCouponAward(awardId, agentNo);
    }

    /**
     * 024邀请助力导出EXCEL
     *
     * @param awardId
     * @return
     */
    public List<ExportAwardVO> exportACTE024CouponAward(List<Long> awardId, String agentNo) {
        return fansAwardMapper.exportACTE024CouponAward(awardId, agentNo);
    }

    /**
     * 025会员福利导出EXCEL
     *
     * @param awardId
     * @return
     */
    public List<ExportAwardVO> exportACTE025CouponAward(List<Long> awardId, String agentNo) {
        return fansAwardMapper.exportACTE025CouponAward(awardId, agentNo);
    }

    /**
     * 026商家自主发券导出EXCEL
     *
     * @param awardId
     * @return
     */
    public List<ExportAwardVO> exportACTE026CouponAward(List<Long> awardId, String agentNo) {
        return fansAwardMapper.exportACTE026CouponAward(awardId, agentNo);
    }

    /**
     * 027老客唤醒活动导出EXCEL
     *
     * @param awardId
     * @return
     */
    public List<ExportAwardVO> exportACTE027CouponAward(List<Long> awardId, String agentNo) {
        return fansAwardMapper.exportACTE027CouponAward(awardId, agentNo);
    }

    /**
     * 028商户资产提升活动导出EXCEL
     *
     * @param awardId
     * @return
     */
    public List<ExportAwardVO> exportACTE028CouponAward(List<Long> awardId, String agentNo) {
        return fansAwardMapper.exportACTE028CouponAward(awardId, agentNo);
    }

    /**
     * 029码上有福活动导出EXCEL
     *
     * @param awardId
     * @return
     */
    public List<ExportAwardVO> exportACTE029CouponAward(List<Long> awardId, String agentNo) {
        return fansAwardMapper.exportACTE029CouponAward(awardId, agentNo);
    }

    /**
     * 实名信息导出EXCEL
     *
     * @param fansAuthDTO
     * @return
     */
    public List<ExportAwardVO> exportReal(FansAuthDTO fansAuthDTO) {
        return fansAwardMapper.exportReal(fansAuthDTO);
    }

    /**
     *
     * acte017 导出卡券奖品
     * @param awardType
     * @param awardId
     * @return
     */
    public List<Acte017ExportVO> exportACTE017CouponAward(String awardType, String awardId) {
        return this.fansAwardMapper.exportACTE017CouponAward(awardType, awardId);
    }

    /**
     * acte017 导出实物奖品
     * @param awardType
     * @param awardId
     * @return
     */
    public List<Acte017ExportVO> exportACTE017GoodsAward(String awardType, String awardId) {
        return this.fansAwardMapper.exportACTE017GoodsAward(awardType, awardId);
    }

    /**
     * acte017 导出积分奖品
     * @param activityId
     * @return
     */
    public List<Acte017ExportVO> exportACTE017ScoreAward(String activityId) {
        return this.fansAwardMapper.exportACTE017ScoreAward(activityId);
    }

    /**
     * 获取 ACTE017越减越便宜活动--用户参与记录明细
     * @param page
     * @return
     */
    public IPage<StatActe017RecordEntity> getStatActe017Record(Page page) {
        return this.fansAwardMapper.getStatActe017Record(page);
    }

    /**
     * 获取ACTE017 根据appid 和机构ID 的数量
     *
     * @param liteAppIdList
     * @param activityIdList
     * @param agentNoList
     * @return
     */
    public List<Map<String, Object>> getActivateCount(List<String> liteAppIdList, List<Long> activityIdList, List<String> agentNoList) {
        return this.fansAwardMapper.getActivateCount(liteAppIdList, activityIdList, agentNoList);
    }
}
